﻿using System;
using System.Data;
using System.Collections.Generic;
using EAS.Data.Access;
using EAS.Data.ORM;
using System.Linq;
using System.Runtime.Serialization;

namespace DataStudio
{
    public partial class Group : DataEntity<Group>
    {
        public IList<Group> GetAllGroup()
        {
            EAS.Data.Linq.DataEntityQuery<Group> query =
                EAS.Data.Linq.DataEntityQuery<Group>.Create();

            var p = from item in query
                    select item;
            return p.ToList();
        }

        public Group[] GetGroups()
        {
            IList<Group> GroupList = this.GetAllGroup();
            List<Group> list = new List<Group>(GroupList.Count);
            foreach (Group g in GroupList)
            {
                list.Add(g);
            }

            Group[] gp = new Group[GroupList.Count];
            list.CopyTo(gp);
            return gp;
        }

        public Group GetGroupByID(int ID)
        {
            EAS.Data.Linq.DataEntityQuery<Group> query =
                EAS.Data.Linq.DataEntityQuery<Group>.Create();

            var p = from items in query
                    where items.ID == ID
                    select items;
            return p.ToList()[0];
        }
    }
}